/*
 * @Descripttion: GGB
 * @version: 1.0
 * @Author: GGB
 * @Date: 2021-08-18 15:52:39
 * @LastEditors: GGB
 * @LastEditTime: 2021-08-18 16:41:52
 */
import 'package:flutter/material.dart';
import 'package:flutter_data_center/components/loading.dart';
import 'package:flutter_data_center/controller/broadcast_controller.dart';
import 'package:get/get.dart';

import 'broadcast_item.dart';

class BroadcastList extends StatelessWidget {
  const BroadcastList({Key key, this.currentIndex, this.onChange})
      : super(key: key);
  final int currentIndex;
  final ValueChanged<int> onChange;

  @override
  Widget build(BuildContext context) => GetBuilder<BroadcaseController>(
        builder: (_controller) => _controller.taskList.length > 0
            ? ListView.builder(
                physics: BouncingScrollPhysics(),
                itemCount: _controller.taskList.length,
                itemBuilder: (context, index) => GestureDetector(
                  onTap: () => onChange(index),
                  child: BroadcastItem(
                      task: _controller.taskList[index],
                      show: index == currentIndex),
                ),
              )
            : Loading(),
      );
}
